﻿using Microsoft.EntityFrameworkCore.ChangeTracking;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Fast.Extensions.DatabaseAccessor.EntityFrameworkCore
{
    /// <summary>
    /// 删除仓储接口
    /// </summary>
    public interface IDeletableRepository<TEntity> : IRootDeletableRepository<TEntity, DefaultDbContextLocator>
        where TEntity : class, IRootEntity, new()
    {

    }

    /// <summary>
    /// 删除仓储接口
    /// </summary>
    public interface IRootDeletableRepository<TEntity, TDbContextLocator> : IRootDeletableRepository<TEntity>
        where TEntity : class, IRootEntity, new()
        where TDbContextLocator : class, IDbContextLocator
    {
    }
    /// <summary>
    /// 删除仓储接口
    /// </summary>
    public interface IRootDeletableRepository<TEntity> : IRootRepositoryBase
    where TEntity : class, IRootEntity, new()
    {
        /// <summary>
        /// 删除一条记录
        /// </summary>
        /// <param name="entities">多个实体</param>
        void Delete(TEntity entity);
        /// <summary>
        /// 删除一条记录并返回跟踪信息的实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>代理中的实体</returns>
        EntityEntry<TEntity> DeleteWithReturnEntity(TEntity entity);
        /// <summary>
        /// 删除多条记录
        /// </summary>
        /// <param name="entities">多个实体</param>
        void Delete(IEnumerable<TEntity> entities);
        /// <summary>
        /// 删除一条记录并立即提交
        /// </summary>
        /// <param name="entities">多个实体</param>
        void DeleteAndCommit(TEntity entity);
        /// <summary>
        /// 删除一条记录并立即提交，返回跟踪信息的实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>代理中的实体</returns>
        EntityEntry<TEntity> DeleteAndCommitWithReturnEntity(TEntity entity);
        /// <summary>
        /// 删除多条记录并立即提交
        /// </summary>
        /// <param name="entities">多个实体</param>
        void DeleteAndCommit(IEnumerable<TEntity> entities);
        /// <summary>
        /// 删除一条记录
        /// </summary>
        /// <param name="entities">多个实体</param>
        Task DeleteAsync(TEntity entity);
        /// <summary>
        /// 删除一条记录并返回跟踪信息的实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>代理中的实体</returns>
        Task<EntityEntry<TEntity>> DeleteWithReturnEntityAsync(TEntity entity);
        /// <summary>
        /// 删除多条记录
        /// </summary>
        /// <param name="entities">多个实体</param>
        Task DeleteAsync(IEnumerable<TEntity> entities);
        /// <summary>
        /// 删除一条记录并立即提交
        /// </summary>
        /// <param name="entities">多个实体</param>
        Task DeleteAndCommitAsync(TEntity entity, CancellationToken cancellationToken = default);
        /// <summary>
        /// 删除一条记录并立即提交，返回跟踪信息的实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>代理中的实体</returns>
        Task<EntityEntry<TEntity>> DeleteAndCommitWithReturnEntityAsync(TEntity entity, CancellationToken cancellationToken = default);
        /// <summary>
        /// 删除多条记录并立即提交
        /// </summary>
        /// <param name="entities">多个实体</param>
        Task DeleteAndCommitAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken = default);

    }
}
